#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i <= n; i++)
	{
		int sq = i * i;
		int tmp1 = i;
		int tmp2 = sq;
		while (tmp1)
		{
			if (tmp1 % 10 != tmp2 % 10)
				break;
			tmp1 /= 10;
			tmp2 /= 10;
		}
		if (tmp1 == 0)
			count++;
	}
	cout << count << endl;
	return 0;
}